﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Piser.Controls
{
   
    public class Button : Piser.Common.ContentElement 
    {
        public Button()
        {
            this.DefaultStyleKey = typeof(Button);
            this.MouseLeftButtonUp += UIElement_MouseLeftButtonUp;
            this.MouseLeftButtonDown += UIElement_MouseLeftButtonDown;
        }

        int hits = 0;

        private void UIElement_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            hits++;
        }

        private void UIElement_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            hits++;
            if (hits % 2 != 0)
            {
                hits = 0;
            }
            else
            {
                hits = 0;
                if (this.Click != null)
                {
                    this.Click.Invoke(sender, new RoutedEventArgs());
                }
            }
        }


        public event RoutedEventHandler Click;
    }
}
